#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar* menuBar=new QMenuBar();
    this->setMenuBar(menuBar);
    //子菜单
    QMenu* menuParent=new QMenu("父菜单");
    QMenu* menuSon=new QMenu("子菜单");
    this->setMenuBar(menuBar);
    menuBar->addMenu(menuParent);
    menuParent->addMenu(menuSon);
    //给子菜单添加活动
    QAction* action1=new QAction("活动1");
    QAction* action2=new QAction("活动2");
    menuSon->addAction(action1);
    menuSon->addSeparator();//添加分割线
    menuSon->addAction(action2);
    //给菜单添加图标
    QIcon icon1(":/save.png");
    action1->setIcon(icon1);
}

MainWindow::~MainWindow()
{
    delete ui;
}

